package com.sc.general.configration;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Value("${sc.file.path}")
    private String path;

    /*
    * url映射磁盘路径
    * */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String p = "file:" + path;
        System.out.println(p);
        registry.addResourceHandler("/sc/**").addResourceLocations(p);
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*")
                .allowedHeaders("*")//允许的方法
                .allowedMethods("*").maxAge(30 * 1000);
    }

}